﻿@using NGroup.VTL.Models;
@using System.Collections.Generic;
@using NGroup.VTL.Core.Const;
@using NGroup.VTL.WebCore;
@model List<TranslationModel>
@{
    ViewBag.Title = "Quản trị - Đa ngôn ngữ";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
    int index = 0;
}
@section Head{
    <style type="text/css">
        #viewTrans td
        {
            vertical-align: top;       
            width: auto;    
        }
        
       @* #viewTrans td input
        {
            width: 100% !important;
        }*@
        
        #viewTrans tr > td:first-child
        {
            padding-top: 5px;
            padding-right: 10px;
            text-align: right;
        }  
        
        #facebox td.body
        {
            width: 400px !important;
        }
        
        #fbLink
        {
            line-height: 21px;
        }
        
        #viewTrans
        {
            width: 100%;
        }
    </style>
}
<div class="clear">
</div>
<!-- End .clear -->
<div class="content-box">
    @using (Html.BeginForm("quan-ly-don-hang", "vuarao", FormMethod.Post, new { id = "frmPaging" }))
    {
        <!-- Start Content Box -->
        <div class="content-box-header">
            <h3>
                Quản lý chuyển ngữ</h3>
            <div class="clear">
            </div>
        </div>
        <div class="clear">
        </div>
        <!-- End .content-box-header -->
        <div class="content-box-content">
            <div class="tab-content default-tab" id="tab1">
                @if (Model != null && Model.Count > 0)
                {
                    <table>
                        <thead>
                            <tr>
                                <th>
                                    #
                                </th>
                                <th>
                                    Tiếng Việt
                                </th>
                                <th>
                                    Tiếng Anh
                                </th>
                                <th>
                                    Ghi chú
                                </th>
                                <th>
                                    &nbsp;
                                </th>
                            </tr>
                        </thead>
                        @*<tfoot>
                            <tr>
                                <td colspan="5">
                                    @Html.Partial("PagingPartial", pagingInfo)
                                </td>
                            </tr>
                        </tfoot>*@
                        <tbody>
                            @foreach (TranslationModel item in Model)
                            {
                                index++;
                                
                                <tr>
                                    <td>
                                        @index
                                        <input class="transKey" type="hidden" value="@item.Key" />
                                    </td>
                                    <td>
                                        <span class="transVi">@item.Vietnamese</span>
                                    </td>
                                    <td>
                                        <span class="transEn">@item.English</span>
                                    </td>
                                    <td>
                                        <span class="transComment">@item.Comment</span>
                                    </td>
                                    <td>
                                        <!-- Icons -->
                                        <a href="#formViewTrans" title="View" rel="modal" class="btnViewTrans">
                                            <img src="@Url.Content("~/Content/adminpages/images/icons/eye.png")" alt="View" /></a>
                                        @*<a href="/vuarao/delete-order/@item.ID" class="btnDelete" title="Delete">
                                            <img src="@Url.Content("~/Content/adminpages/images/icons/cross.png")" alt="Delete" /></a>*@
                                    </td>
                                </tr>
                            }
                        </tbody>
                    </table>
                }
                else
                {
                    <div style="padding: 20px;">
                        <p>
                            Hiện tại chưa có chuyển ngữ nào!
                        </p>
                    </div>
                }
            </div>
        </div>
        <!-- End .content-box-content -->
    }
    <div class="nodisplay">
        @using (Html.BeginForm("chinh_sua_chuyen_ngu", "vuarao", FormMethod.Post, new { @id = "formViewTrans" }))
        {
            <table id="viewTrans">
                <tr>
                    <td>
                        Tiếng Việt
                    </td>
                    <td>
                        <input class="text-input medium-input" id="fbVi" type="text" name="transVi" />
                        <input class="text-input medium-input" id="fbKey" type="hidden" name="transKey" />
                    </td>
                </tr>
                <tr>
                    <td>
                        Tiếng Anh
                    </td>
                    <td>
                        <input class="text-input medium-input" id="fbEn" type="text" name="transEn"/>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <input type="submit" id="btnSave" class="button" value="Lưu" />
                    </td>
                </tr>
            </table>
        }
    </div>
</div>
@section Lazy{
    <script type="text/javascript">
        $(".current").removeClass("current");
        $("#qlcn").addClass("current");

        $(document).ready(function () {

            $(".btnViewTrans").click(function () {
                var currentRow = $(this).parents("tr").get(0);

                if (!currentRow == false) {
                    var vi = $($(currentRow).find("td .transVi").get(0)).text();
                    var en = $($(currentRow).find("td .transEn").get(0)).text();
                    var key = $($(currentRow).find("td .transKey").get(0)).val();

                    $("#facebox #fbVi").val(vi);
                    $("#facebox #fbEn").val(en);
                    $("#facebox #fbKey").val(key);
                }
            });

        });        

    </script>
}
